package study.zhangxh.annotations.validate;

import study.zhangxh.annotations.UseCase;

import java.lang.reflect.Method;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

/**
 * 说明 用于读取注解的类
 *
 * @author: zhangxh
 * @email: zhangxh@cheegu.com
 * @date: 2018/6/14 21:55
 */
public class UseCaseTracker {
    public static void trackUseCases(List<Integer> useCases, Class<?> cl) {

        //反射获取所有生命方法
        for (Method m : cl.getDeclaredMethods()) {//
            UseCase useCase=m.getAnnotation(UseCase.class);
            if (useCase != null) {
                System.out.println("Found Use Case:" + useCase.id() + " " + useCase.description());
                useCases.remove(new Integer(useCase.id()));
            }
        }
        for (int i : useCases) {
            System.out.println("Warning:Missing use case-" + i);
        }
    }

    public  static void  main(String[] args) {
        List<Integer> useCases = new ArrayList<>();
        Collections.addAll(useCases,47,48,49,50);
        trackUseCases(useCases, PassWordUtils.class);
    }
}
